﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace ExamRepositoryWebAPI.Models
{
    public class SingleChoiceQuestion
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int QuestionID { get; set; }

        public int Level { get; set; }

        public string Content { get; set; }

        /// <summary>
        /// 选项列表的json字符串
        /// </summary>
        private List<string> sections;
        public string Sections
        {
            get
            {
                return JsonConvert.SerializeObject(sections);
            }
            set
            {
                sections = JsonConvert.DeserializeObject<List<string>>(value);
            }
        }

        public int Answer { get; set; }

        [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
        public DateTime LastModified { get; set; }
    }
}
